Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

417
Vistas
Axios Delete operation on React-bootstrap-table displaying [object%20Object] on the browser's console

I am trying to perform an axios delete operation on a react-bootstrap-table, but I am getting this error on the console

  DELETE http://localhost:9000/api/terminals/[object%20Object]
  Uncaught (in promise) Error: Request failed with status code 400

These are the codes

const

  const apiUrl = 'api/terminals';

UseState and UseEffect

     const [data, setData] = useState([]);

       useEffect(() => {
       getData();
       }, []);

      const getData = () => {
     axios(apiUrl).then(res => {
     setData(res.data);
    });
    };

Axios delete

        const handleDelete = rowId => {
        axios.delete(`${apiUrl}/${rowId}`).then(() => setData(data));
        };

Modal Content

     const ModalContent = () => {
          return (
             <>
      <Modal show={showModal} onHide={handleClose}>
      <Modal.Header closeButton>
        <Modal.Title>Confirm delete operation</Modal.Title>
      </Modal.Header>
      <Modal.Body>Are you sure you want to delete this Terminal? 
      </Modal.Body>
      <Modal.Footer>
        <Button variant="secondary" onClick={handleClose}>
          Cancel
        </Button>
        <Button onClick={id => handleDelete(id)}>Confirm</Button>
      </Modal.Footer>
    </Modal>
   </>
   );
  };

main jsx with bootstrap Table

  <>
  <BootstrapTable
    keyField="id"
    data={data}
    columns={columns}
    striped
    hover
    condensed
    pagination={paginationFactory()}
    cellEdit={cellEdit}
    filter={filterFactory()}
    noDataIndication="Table is Empty"
   
    />
    {showModal ? <ModalContent /> : null}
  </>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You use an object instead of a string in the delete url. Normally you get an event from a onClick and not the id. If you get the id from somewhere else in the code that you do not show the you could try this.

<Button variant="primary" onClick={() => handleDelete(id)}>
   Confirm
</Button>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda